package com.roger.springcloudGreenwich.controller;

import com.roger.springcloudGreenwich.mapper.CommonMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.File;
import java.util.List;

@RestController
@RequestMapping("/file")
public class FileController {

    @Autowired
    private CommonMapper commonMapper;

    @GetMapping("/test")
    public String test(){
        String sql = "select CONCAT('/opt/tools/data/videos/',object_name) as filePath " +
                " from tb_distribute_file where type_id=0 and object_name like '%.mp4' " +
                " ORDER BY id desc";
        List<String> fileList = commonMapper.selectListStrSql(sql);
        //System.out.println(fileList);
        for(String filePath : fileList){
            File file = new File(filePath);
            if(file.exists()){
                continue;
            }
            System.out.println("路径不存在的附件有：" + filePath);
        }
        return "success";
    }
}
